package com.situ.web.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.situ.web.entity.Course;
import com.situ.web.service.ICourseService;
import com.situ.web.service.impl.CourseServiceImpl;

@WebServlet("/test")
public class TestServlet extends HttpServlet{
	private ICourseService courseService = new CourseServiceImpl();

//	@Override
//	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//		
//	}
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// .....
		doPost(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// .....
		List<Course> list = courseService.selectAll();
		
		resp.setContentType("text/html;charset=utf-8");
		PrintWriter writer = resp.getWriter();
		writer.print("<table border='1' cellspacing='0' width='400px'>");
			writer.print("<tr>             ");
			writer.print("	<td>ID</td>    ");
			writer.print("	<td>名字</td>  ");
			writer.print("	<td>年龄</td>  ");
			writer.print("	<td>性别</td>  ");
			writer.print("</tr>            ");
			writer.print("<tr>             ");
			writer.print("	<td>1</td>     ");
			writer.print("	<td>张三</td>  ");
			writer.print("	<td>男</td>    ");
			writer.print("	<td>23</td>    ");
			writer.print("</tr>            ");
			writer.print("<tr>             ");
			writer.print("	<td>2</td>     ");
			writer.print("	<td>李四</td>  ");
			writer.print("	<td>女</td>    ");
			writer.print("	<td>23</td>    ");
			writer.print("</tr>            ");
			writer.print("<tr>             ");
			writer.print("	<td>3</td>     ");
			writer.print("	<td>王五</td>  ");
			writer.print("	<td>女</td>    ");
			writer.print("	<td>23</td>    ");
			writer.print("</tr>            ");
		writer.print("</table>             ");
		
	}
}
